<%@page import="java.util.regex.Pattern"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="cn.kgcnews.pojo.NewsDetail"%>
<%@page import="cn.kgcnews.service.impl.NewsServiceImpl"%>
<%@page import="cn.kgcnews.service.NewsService"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <!--声明文档兼容模式，表示使用IE浏览器的最新模式-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!--设置视口的宽度(值为设备的理想宽度)，页面初始缩放值<理想宽度/可见宽度>-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>新闻浏览页面</title>

    <!-- Bootstrap的样式文件-->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="shortcut icon" href="images/favicon.ico" mce_href="images/favicon.ico" type="image/x-icon" >
    <style>
        .text-content {
            font-size: 16px;
            line-height: 30px;
        }
        .text-red{
            color: red;
        }
        .bbs  li{padding: 10px 0; border-bottom: 1px #999999 dashed;
            overflow: hidden;}
        .bbs  li div{float: left; width: 60px; margin-right: 10px;}
        .bbs  li div img{ border-radius:50%; width: 60px;}
        .bbs  li h1{float: left; width: 520px; font-size: 16px; line-height: 35px;}
        .bbs  li p{color: #666666; line-height: 25px; font-size: 12px; }
    </style>

</head>
<body>
<!--导航栏-->
<%@ include file="header.jsp"%>
<%
   String title="";
   String date="";
   String content="";
   String author="";
   String picPath="";
   NewsService newsService=new NewsServiceImpl();
   String id=request.getParameter("newsid");
   //正则表达式
   String regex="[0-9]+";
   boolean flag=Pattern.matches(regex, id);
   if(!flag){
      out.println("<script>alert('传输数据有误');location.href='index.jsp';</script>");
   }else{
   NewsDetail news=newsService.showNewsDetail(id);
   if(news==null){
     out.println("<script>alert('传输数据有误');location.href='index.jsp';</script>");
   }else{
     title=news.getTitle();
     SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
     date=sdf.format(news.getCreateDate());
     content=news.getContent();
     author=news.getAuthor();
     picPath=news.getPicPath();
   }
%>
<!--通栏广告-->
<div class="container" style="margin-top: -15px">
    <img src="images/wy.jpg" width="100%">
</div>
<div class="container" style="margin-top: 10px">
    <ul class="breadcrumb">
        <li><a href="#">国际</a></li>
        <li class="active">新闻正文</li>
    </ul>
    <h1><%=title %></h1>
    <hr>
    <h3>发布时间：<%=date %> 作者：<%=author %>
        <span class="glyphicon glyphicon-time pull-right">&nbsp;</span>
        <span class="glyphicon glyphicon-fire pull-right">&nbsp;</span>
        <span class="glyphicon glyphicon-eye-open pull-right">&nbsp;</span>
        <span class="glyphicon glyphicon-comment pull-right">&nbsp;</span>
        <span class="glyphicon glyphicon-grain pull-right">&nbsp;</span>
        <span class="glyphicon glyphicon-apple pull-right">&nbsp;</span>
    </h3>
    <hr>
</div>
<div class="container">
    <div class="row">
        <div class="col-md-9">
            <div class="panel panel-default">
                <div class="panel-body text-content">
                    <% 
                      if(picPath!=null && !"".equals(picPath)){
                    %>
                    <p><img src="upload/<%=picPath%>"></p>
                    <%} %>
                    <%=content %>
                </div>
            </div>
            <div class="panel panel-default">
                <h3>&nbsp;&nbsp;<span class="glyphicon glyphicon-th-list">&nbsp;</span>网友评论<small class="pull-right"><span class="text-red">101</span>条评论|<span class="text-red">5759</span>人参与网友评论</small></h3>
                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <label for="username" class="col-sm-2 control-label">用户名</label>
                        <div class="col-sm-10">
                            <textarea id="username" class="form-control" rows="5"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-default">发布</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="panel panel-default">
                <ul class="bbs">
                    <li>
                        <div><img src="images/tou01.jpg"></div>
                        <h1>中国不要怕，也该抓几个美国人了</h1>
                        <p>2018年12月21日</p>
                    </li>
                    <li>
                        <div><img src="images/tou02.jpg"></div>
                        <h1>中国不要怕，也该抓几个美国人了</h1>
                        <p>2018年12月21日</p>
                    </li>
                    <li>
                        <div><img src="images/tou03.jpg"></div>
                        <h1>中国不要怕，也该抓几个美国人了</h1>
                        <p>2018年12月21日</p>
                    </li>
                    <li>
                        <div><img src="images/tou04.jpg"></div>
                        <h1>中国不要怕，也该抓几个美国人了</h1>
                        <p>2018年12月21日</p>
                    </li>
                </ul>
            </div>
        </div>
        <div class="col-md-3">
            <div class="panel panel-default" style="margin-left: -15px">
                <h4 style="text-indent: 1em">推荐新闻</h4>
                <ul class="list-unstyled">
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                </ul>
            </div>
            <div class="panel panel-default" style="margin-left: -15px">
                <img src="images/readad.jpg" width="100%"/>
            </div>
            <div class="panel panel-default" style="margin-left: -15px">
                <h4 style="text-indent: 1em">阅读排行</h4>
                <ul class="list-unstyled">
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                    <li><a href="#">【新闻】</a>&nbsp;&nbsp;<a href="#">特朗普又向普京送了份大礼</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>
<!--友情链接和版权信息-->
<%@ include file="footer.jsp" %>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="js/jquery-1.12.4.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="js/bootstrap.min.js"></script>
<%} %>
</body>
</html>